
// websocket
// websocket
export function websocketInit(userName, webSocketObject) {
    console.log(11)
    // TODO 这边必须要等store里面有才行
    const webSocketUrl = 'ws://localhost:8099/websocket/' + userName;
    try {
        webSocketObject = new WebSocket(webSocketUrl);
    } catch (error) {
        console.log(error);
    }
    webSocketObject.onopen = (e) => webSocketOnOpen(e);
    webSocketObject.onmessage = (e) => webSocketOnMessage(e);
    webSocketObject.onerror = (e) => webSocketOnError(e);
    webSocketObject.onclose = (e) => webSocketOnClose(e);
}

export  function webSocketOnOpen(e) {
    console.log('与服务器连接打开' + e)
}
export  function webSocketOnMessage(e) {
    console.log('来自服务器的消息:' + e)
}
export  function webSocketOnError(e) {
    console.log('与服务器连接异常:' + e)
}
export  function webSocketOnClose(e) {
    console.log('与服务器关闭->' + e)
}